#include "stm32f10x.h"                  // Device header
#include "Delay.h"
#include "LED.h"
#include "timer.h"
#include "Key_sys.h"
#include "ADC_voltage.h"
#include "OLED.h"

double temp1,temp2;

int main(void)
{      
    /*初始化*/
    TIM_Init(); 
    Key_Init();
    ADC_Volt_Init();
    OLED_Init();

    /*标点字母输出*/
    OLED_ShowString(1,1,"Mode:");
    OLED_ShowString(3,1,"Voltage:");
    OLED_ShowString(3,11,".");
    OLED_ShowString(3,14,"V");

    uint8_t value = 0;
    while(1)
    {
        
        if (Key_Input() == 1)  /*按键输入*/
        {
            value += 1;
            Delay_ms(700);
        }
       switch (value)
       {
       case 0:LED_PWM_Control_Step1_Up();    /*PWM呼吸灯一级*/
        break;
       
       case 1:LED_PWM_Control_Step2_Up();    /*PWM呼吸灯二级*/
       break;

       case 2:LED_PWM_Control_Step3_Up();    /*PWM呼吸灯三级*/
       break;

       default :value = 0;                   /*按键值清零回一级*/
        break;
       }

        /*ADC值转换成电压值（3.3/4095）*/
        temp1 = Get_ADC_Data(15)*0.000805;  /*取个数位*/
        temp2 = Get_ADC_Data(15)*0.0805;    /*取小数位*/

        /*OLED打印数据*/
        OLED_ShowNum(1,7,value,1);
        OLED_ShowNum(3,10,temp1,1);
        OLED_ShowNum(3,12,temp2,2);

    }
}

